package com.esri.core.internal.tasks.e.b;

import com.esri.core.ogc.wmts.WMTSServiceMode;
import java.util.HashMap;
import java.util.Map;

/* loaded from: classes.dex */
public class e extends f {
    public static final String a = "RestUrl";
    private static final long serialVersionUID = 1;
    private String e;
    private String f;
    private String g;
    private String h;
    private String i;
    private int j;
    private int k;
    private WMTSServiceMode l;
    private String m;
    private boolean n;

    public e(String str, String str2, String str3, String str4, String str5, int i, int i2) {
        super("GetTile");
        this.e = str;
        this.f = str2;
        this.g = str3;
        this.h = str4;
        this.i = str5;
        this.j = i;
        this.k = i2;
        this.l = WMTSServiceMode.KVP;
    }

    public e(String str, String str2, String str3, String str4, int i, int i2) {
        super("GetTile");
        this.m = str;
        this.f = str2;
        this.h = str3;
        this.i = str4;
        this.j = i;
        this.k = i2;
        this.l = WMTSServiceMode.REST;
    }

    public WMTSServiceMode a() {
        return this.l;
    }

    public void a(boolean z) {
        this.n = z;
    }

    /* renamed from: com.esri.core.internal.tasks.e.b.e$1  reason: invalid class name */
    /* loaded from: classes.dex */
    static /* synthetic */ class AnonymousClass1 {
        static final /* synthetic */ int[] a;

        static {
            int[] iArr = new int[WMTSServiceMode.values().length];
            a = iArr;
            try {
                iArr[WMTSServiceMode.KVP.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[WMTSServiceMode.REST.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
        }
    }

    @Override // com.esri.core.internal.tasks.f
    public boolean validate() {
        int i = AnonymousClass1.a[this.l.ordinal()];
        if (i != 1) {
            if (i != 2) {
                return false;
            }
            return e();
        }
        return b();
    }

    @Override // com.esri.core.internal.tasks.e.b.f, com.esri.core.internal.tasks.f
    public Map<String, String> generateRequestParams() {
        int i = AnonymousClass1.a[this.l.ordinal()];
        if (i != 1) {
            if (i != 2) {
                return null;
            }
            return f();
        }
        Map<String, String> generateRequestParams = super.generateRequestParams();
        b(generateRequestParams);
        return generateRequestParams;
    }

    private boolean b() {
        return (a(this.e) || a(this.f) || a(this.g) || a(this.h) || a(this.i) || this.j < 0 || this.k < 0) ? false : true;
    }

    private boolean e() {
        return (a(this.m) || a(this.f) || a(this.h) || a(this.i) || this.j < 0 || this.k < 0) ? false : true;
    }

    private void b(Map<String, String> map) {
        map.put("Layer", this.e);
        map.put("Style", this.f);
        map.put("Format", this.g);
        map.put("TileMatrixSet", this.h);
        map.put("TileMatrix", this.i);
        map.put("TileRow", Integer.valueOf(this.j).toString());
        map.put("TileCol", Integer.valueOf(this.k).toString());
    }

    private Map<String, String> f() {
        String a2;
        HashMap hashMap = new HashMap();
        String str = this.m;
        if (this.n) {
            a2 = a(a(a(str, "level", this.i), "row", Integer.valueOf(this.j).toString()), "col", Integer.valueOf(this.k).toString());
        } else {
            a2 = a(a(a(a(a(str, "Style", this.f), "TileMatrixSet", this.h), "TileMatrix", this.i), "TileRow", Integer.valueOf(this.j).toString()), "TileCol", Integer.valueOf(this.k).toString());
        }
        hashMap.put(a, a2);
        return hashMap;
    }

    private String a(String str, String str2, String str3) {
        String str4;
        int indexOf;
        if (str.toLowerCase().indexOf("{" + str2.toLowerCase() + "}") > -1) {
            return str.substring(0, indexOf) + str3 + str.substring(indexOf + str4.length());
        }
        return str;
    }

    private boolean a(String str) {
        return str == null || str.isEmpty();
    }
}
